package ch13_swing_components;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class JHello extends JFrame implements ActionListener
{
   JLabel greeting = new JLabel("What is your name?");
   Font bigFont = new Font("Helvetica", Font.BOLD, 16);
   JTextField answer = new JTextField(10);
   JButton pressMe = new JButton("Press me");
   public JHello()
   {
      super("Hello Frame");
      setLayout(new FlowLayout());
      greeting.setFont(bigFont);
      add(greeting);
      add(answer);
      add(pressMe);
      setVisible(true);
      pressMe.addActionListener(this);
    }
    public void actionPerformed(ActionEvent e)
    {
       String name = answer.getText();
       JLabel helloLabel = new JLabel("Hello, " + name);
       helloLabel.setFont(bigFont);
       add(helloLabel);
    }
}
